package com.jimmy.medical.entity;

import lombok.Data;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * @author jimmy
 * @Desc: 工单 - 订单按流程划分成工单
 * @date 2018-04-03
 */
@Data
@Entity
@Table(name = "flow_order")
public class FlowOrder extends AbstractEntity {

    /**
     * 所属订单
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "order_id")
    @NotFound(action = NotFoundAction.IGNORE)
    private Order order;

    /**
     * 工单类型
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "flow_order_type_id")
    @NotFound(action = NotFoundAction.IGNORE)
    private FlowOrderType flowOrderType;

    /**
     * 订单类型
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "order_type")
    @NotFound(action = NotFoundAction.IGNORE)
    private OrderType orderType;

    /**
     * 当前步骤 - 与FlowOrderType.FlowOrderServiceItem.itemOrder的值对应
     */
    @Column(name = "current_step")
    private Integer currentStep;

    /**
     * 是否需要致电客户
     */
    @Column(name = "is_need_dail_to_member")
    private Integer isNeedDailToMember;

    /**
     * 处理人
     */
    @ManyToOne(fetch =  FetchType.LAZY)
    @JoinColumn(name = "user_id")
    @NotFound(action = NotFoundAction.IGNORE)
    private User user;

    /**
     * 创建时间
     */
    @Column(name = "create_time")
    private Date createTime;

    /**
     * 更新时间,只在每一步流程更新,用于计算倒计时
     */
    @Column(name = "update_time")
    private Date updateTime;

    /**
     * 是否已派单-新工单值为0，中台派单后变为1，被退单后也变为0
     */
    @Column(name = "is_assign")
    private Short isAssign;

    /**
     * 是否存在超时处理，只要某一个步骤超时，则该工单被定为超时
     */
    @Column(name = "is_over_time")
    private Short isOverTime;

    /**
     * 是否已完成
     */
    @Column(name = "is_finish")
    private Short isFinish;

    /**
     * 是否评价
     */
    @Column(name = "is_evaluate")
    private Short isEvaluate;

    /**
     * 是否结算
     */
    @Column(name = "is_settle")
    private Short isSettle;

    /**
     * 得分
     */
    @Column(name = "score")
    private Short score;

    /**
     * 应得提成
     */
    @Column(name = "money", columnDefinition = "decimal(7,2)")
    private Double money;

    @Transient
    private Long countDown;

    @Transient
    private List<FlowOrderLog> logList;

    @Transient
    private List<UploadFile> needPicList;

    @Transient
    private List<UploadFile> needDocList;
}
